<template>
  <div class="search" v-show="isSearch">
    <div class="search-inner">
      <span>模糊查询</span>
      <el-input v-model="searchList.FuzzySearch" />
    </div>
    <div class="search-inner">
      <span>电话号码</span>
      <el-input v-model="searchList.PhoneNumber" />
    </div>
    <div class="search-inner">
      <span>车牌号码</span>
      <el-input v-model="searchList.carNumber" />
    </div>
    <div>
      <el-button type="primary" :icon="Search">搜索</el-button>
      <el-button :icon="Refresh">重置</el-button>
    </div>
  </div>
  <div class="add">
    <el-button color="#1890ff" plain>+ 新增</el-button>
  </div>
  <div class="icon">
    <el-tooltip
      class="box-item"
      effect="dark"
      content="隐藏搜索"
      placement="top"
    >
      <el-button :icon="Search" size="small" circle @click="handIsSearch" />
    </el-tooltip>
    <el-tooltip class="box-item" effect="dark" content="刷新" placement="top">
      <el-button :icon="Refresh" size="small" circle />
    </el-tooltip>
  </div>
  <el-table
    :data="getMentList"
    cell-class-name="align-c"
    table-layout="auto"
    border
  >
    <el-table-column prop="customerName" label="客户名称" width="140px" />
    <el-table-column prop="customerPhone" label="联系方式" width="140px" />
    <el-table-column prop="appointmentTime" label="预约时间" width="180px" />
    <el-table-column prop="actualArrivalTime" label="到店时间" width="180px" />
    <el-table-column prop="licensePlate" label="车牌号码" width="140px" />
    <el-table-column prop="carSeries" label="汽车类型" width="140px" />
    <el-table-column prop="serviceType" label="服务类型" />
    <el-table-column prop="info" label="备注" width="300px" />
    <el-table-column prop="status" label="状态" />
    <el-table-column label="操作" width="200px">
      <el-button type="text">
        <el-icon><EditPen /></el-icon>
        <span> 编辑 </span>
      </el-button>
      <el-button type="text">
        <el-icon><Delete /></el-icon>
        <span> 到店 </span>
      </el-button>
      <el-button type="text">
        <el-icon><Delete /></el-icon>
        <span> 结算单 </span>
      </el-button>
    </el-table-column>
  </el-table>
  <ElConfigProvider :locale="zhCn">
    <div class="page">
      <el-pagination
        v-model:current-page="queryParams.pageNum"
        v-model:page-size="queryParams.pageSize"
        :page-sizes="[10, 20, 50, 100]"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="getMent"
        @current-change="getMent"
      />
    </div>
  </ElConfigProvider>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
import { getApiontmentApi } from "./api/index";
import { EditPen, Delete, Search, Refresh } from "@element-plus/icons-vue";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";

const isSearch = ref(true);
const searchList = reactive({
  FuzzySearch: "",
  PhoneNumber: "",
  carNumber: "",
});
const queryParams = reactive<IapmParams>({
  pageNum: 1,
  pageSize: 10,
});
const getMentList = ref<IapmList[]>([]);
const total = ref(0);

const handIsSearch = () => {
  isSearch.value = !isSearch.value;
};

const getMent = () => {
  getApiontmentApi(queryParams).then((res) => {
    if (res.code === 200) {
      getMentList.value = res.rows;
      total.value = res.total;
    }
  });
};

getMent();
</script>
<style lang="less" scoped>
:deep(.align),
:deep(.cell) {
  text-align: center;
}
.search {
  display: flex;
  line-height: 30px;
  margin-bottom: 20px;

  .search-inner {
    display: flex;
    padding-right: 10px;

    span {
      width: 110px;
    }
  }
}
.add {
  margin-bottom: 10px;
  float: left;
}
.icon {
  float: right;
}
.page {
  padding: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>
